﻿using CodeCreator;
using CodeCreator.Template;
using iBing.Common.DbHelper;
using iBing.Common.DbHelper.CoreObj;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeTemplate.CodeEdit
{
    public class ToolForGetJavaFields
    {
        public static List<ObjJavaField> getJavaFields(List<DbField> dbFields, List<TypeMap> typeMap)
        {
            List<ObjJavaField> result = new List<ObjJavaField>();
            foreach (DbField f in dbFields)
            {
                ObjJavaField jf = new ObjJavaField();
                jf.FieldName = Tools.DbFile2JavaFieldWidtFirstLower(f.FieldName);
                if (Tools.GetTypeMapByDb(typeMap, f.FieldType) != null)
                {
                    jf.FieldType = Tools.GetTypeMapByDb(typeMap, f.FieldType).ClassType;
                }
                jf.DbFieldType = f.FieldType;
                jf.DbFieldName = f.FieldName;
                jf.DbFieldLength = f.FieldLength;
                jf.IsPk = f.IsPk;
                result.Add(jf);
            }
            return result;
        }
    }
}
